package com.hlingsoft.cms.action;

import com.hlingsoft.cms.action.manage.ManageBaseAction;
import com.hlingsoft.cms.dao.DecorationDao;
import com.hlingsoft.cms.entity.Decoration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by selbylei on 2015/6/8.
 */
@Controller
@RequestMapping("/decoration")
public class DecorationAction extends ManageBaseAction {

    @Autowired
    private DecorationDao decorationDao;




    /**
     * 列出装饰
     * @param type
     * @param request
     * @return
     */
    @RequestMapping(value = "/list.json")
    @ResponseBody
    public Map<String, Object> list(

            @RequestParam(value = "type") int type, //造型，装饰，背景
            HttpServletRequest request) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        try {
            List<Decoration> decorationList = decorationDao.getDecoration(type);
            resultMap.put("decorationList",decorationList);
            resultMap.put("result",true);
        } catch (Exception e) {
            e.printStackTrace();
            resultMap.put("result", false);
        }
        return resultMap;
    }

}
